package cn.getech.data.development.function

import cn.getech.data.development.sink.jdbc.config.CustomTableConfig
import cn.getech.data.development.utils.{AVSCFileUtils}
import org.apache.avro.generic.{GenericData, GenericRecord}
import org.apache.flink.api.common.functions.MapFunction
import org.apache.flink.types.Row

/**
 * parquet 转成string
 * @param conf 配置信息
 */
class HDFSParquetStringMapFunction(conf: CustomTableConfig) extends MapFunction[Row, GenericRecord] {
  override def map(t: Row): GenericRecord = {
    val record: GenericData.Record = new GenericData.Record(AVSCFileUtils.schema(conf.getParams))
    for (i <- 0 until conf.getParamSize)
        record.put(i, t.getField(i))
    record
  }
}
